#include "foodorderitem.h"
#include "ui_FoodOrderItem.h"

FoodOrderItem::FoodOrderItem(QListWidget *parent) :
    QListWidget(parent),
    ui(new Ui::FoodOrderItem)
{
    ui->setupUi(this);
}

FoodOrderItem::~FoodOrderItem()
{
    delete ui;
}

//初始化ui界面
void FoodOrderItem::init(QString name, int price){
    ui->name_label->setText(name);
    ui->price_label->setText(QString::number(price));

}

//点击购买食物
Food FoodOrderItem::on_buy_btn_clicked(){
    Food food;
    food.name = ui->name_label->text();
    food.price = ui->price_label->text().toInt();
    food.content = "";
    food.is_null = 0;
    emit addIntoShopCart(food); //发送信号通知ListWidget
    return food;
}
